﻿#define _CRT_SECURE_NO_WARNINGS 1
#include"string.h"
void test1()
{
	bit::string s1("hello");
	cout << s1.c_str() << endl;

	bit::string s2("hello");
	cout << s2.c_str() << endl;
	//for (int i = 0; i < s2.size(); i++)
	//{
	//	s2[i]++;
	//	cout << s2[i] << " ";
	//}
	bit::string::iterator it1 = s2.begin();
	while (it1!=s2.end())
	{
		cout << *it1 << " ";
		it1++;
	}
}

void test2()
{
	//const bit::string s1("hello");
	//bit::string::const_iterator it1 = s1.begin();
	//while (it1 != s1.end())
	//{
	//	cout << *it1 << " ";
	//	it1++;
	//}	
	//for (auto e : s1)
	//{
	//	cout << e << " ";
	//}
	//for (int i = 0; i < s1.size(); i++)
	//{
	//	cout << s1[i] << " ";
	//}
	//cout << endl;
	bit::string s2("hello world");
	bit::string::iterator it2 = s2.begin();
	for (int i = 0; i < s2.size(); i++)
	{
		s2[i] = 'a';
		cout << s2[i] << " ";
	}
	//for (auto e : s2)
	//{
	//	cout << e << " ";
	//}
	//cout << endl;
	//for (int i = 0; i < s1.size(); i++)
	//{
	//	cout << s1[i] << " ";
	//}

}

void test3()
{
	bit::string s1("hello");
	//s1.append("hhhh");
	//bit::string::iterator it1 = s1.begin();
	//while (it1 != s1.end())
	//{
	//	cout << *it1 << " ";
	//	it1++;
	//}
	//cout << endl;
	s1 += "hhhhhhh";
	for (int i = 0; i < s1.size(); i++)
	{
		cout << s1[i] << " ";
	}
	cout << endl;
}


void test4()
{
	bit::string s1("hello");
	s1.insert(2, "xxx");
	//for (int i = 0; i < s1.size(); i++)
	//{
	//	cout << s1[i];
	//}
	cout << s1.c_str();
}

void test5()
{
	bit::string s1("hello world");
	cout << s1.find('o') << endl;
	cout << s1.find('h') << endl;
	cout << s1.find("hell") << endl;
}

void test6()
{
	bit::string s1("hello world");
	bit::string s2(s1);
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
}

void test7()
{
	bit::string s1("hello world");
	bit::string s3("yyyy");
	swap(s1, s3);
	cout << s1.c_str() << endl;
	cout << s3.c_str() << endl;
	// std::swap(s1, s3);
	s1 = s3;
	cout << s1.c_str() << endl;
	cout << s3.c_str() << endl;
}

void test8()
{
	bit::string url("https://gitee.com/ailiangshilove/cpp-class/blob/master/%E8%AF%BE%E4%BB%B6%E4%BB%A3%E7%A0%81/C++%E8%AF%BE%E4%BB%B6V6/string%E7%9A%84%E6%8E%A5%E5%8F%A3%E6%B5%8B%E8%AF%95%E5%8F%8A%E4%BD%BF%E7%94%A8/TestString.cpp");
	size_t pos1 = url.find(':');
	bit::string url1 = url.substr(0, pos1 - 0);
	cout << url1.c_str() << endl;

	size_t pos2 = url.find('/', pos1 + 3);
	bit::string url2 = url.substr(pos1 + 3, pos2 - (pos1 + 3));
	cout << url2.c_str() << endl;

	bit::string url3 = url.substr(pos2 + 1);
	cout << url3.c_str() << endl;
}

void test9()
{
	bit::string s1("hello world");
	cin >> s1;
	cout << s1;
}
int main()
{

	test9();
	return 0;
}